/**
 * @file   Array.h
 * @author Heyu Wang <hywang@walker-9>
 * @date   Mon Oct 19 10:12:55 2020
 * 
 * @brief An implementation of static list.
 * 
 * 
 */

/**
 * Array as an example of static lists. 
 * 
 */
class Array{
private:
    double *data;		/**< To store the data elements. */
    int length;			/**< The total number of stored elements. */
public:
    /** 
     * Default constructor.
     * 
     */
    Array();

    /** 
     * Constructor. Only set the length of the list.
     * 
     * @param _len The length.
     */
    Array(int _len);

    /** 
     * Constructor. Set the length of the list, and all elements are
     * initialized by the given value.
     * 
     * @param _len The length.
     * @param _val The initial value for all elements.
     */
    Array(int _len, double _val);

    /** 
     * Default destructor.
     * 
     */
    ~Array();

    /** 
     * Get the value of the @p _idx -th element. 
     * 
     * @param _idx The index.
     * 
     * @return The value.
     */
    double get_ele_val(int _idx);

    /** 
     * Get the address of the @p _idx -th element.
     * 
     * @param _idx The index.
     * 
     * @return The value.
     */
    double* get_ele_add(int _idx);

    /** 
     * Set the value of the @p _idx -th element.
     * 
     * @param _idx The index.
     * @param _val The value.
     */
    void set_ele_val(int _idx, double _val);

    /** 
     * List all the elements by std::cout.
     * 
     */
    void list();

    /** 
     * Resize the list, all the old elements will BE DESTROYED!
     * 
     * @param _len The new length.
     */
    void reinit(int _len);

    /** 
     * Resize and initialize the list, all the old elements will BE
     * DESTROYED! And all new elements will set to the value of 
     * @p _val .
     * 
     * @param _len The new length. 
     * @param _val The initial value.
     */
    void reinit(int _len, double _val);

    /** 
     * Return the length of the list.
     * 
     * 
     * @return The length.
     */
    int get_size();
};
